var __extends = this.__extends || function (d, b) {
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var UsersList = (function (_super) {
    __extends(UsersList, _super);
    function UsersList() {
        _super.apply(this, arguments);

    }
    UsersList.prototype.Ready = function () {
        var urlSetFilter = this.aUrl[0];
        var urlCheck = this.aUrl[1];
        var urlSync = this.aUrl[2];
        $(this.options.isFiltered == 1 ? "#radio1" : "#radio2").attr("checked", "checked");
        $("#radio1,#radio2").click(function () {
            CallService("GET", urlSetFilter, {
                type: this.value
            }, true, function () {
                window.location.reload(true);
            });
        });
        $("#checkusers").click(function () {
            return Base.Page.Self.dialogCheckUsers(urlCheck, urlSync);
        });
        $.templates({
            WorkItemTemplate: "<a href='{{:Url}}' target='_blank' data-content='{{:Content}}'>{{:Title}}</a>&nbsp;&nbsp;"
        });
        $.each($(".userlinecontent"), function () {
            var userId = $(this).attr("data-index");
            CallService("GET", Base.Page.Self.aUrl[3], {
                id: userId
            }, true, function (data) {
                if(data) {
                    Base.Page.Self.SetWorkItemLine(data.UserStories, userId, "#imgldw_", "#wip_");
                    Base.Page.Self.SetWorkItemLine(data.Tasks, userId, "#imglts_", "#lts_");
                    Base.Page.Self.SetWorkItemLine(data.Bugs, userId, "#imglbg_", "#lbg_");
                    Base.Page.Self.SetWorkItemLine(data.CheckOuts, userId, "#imgldp_", "#pcs_");
                    $("#score_" + userId).empty().append(data.Score);
                    $("#hours_" + userId).empty().append(data.Hours);
                    $("#tasks_" + userId).empty().append(data.OpenTasks + '/' + data.TotalTasks);
                }
            });
        });
    };
    UsersList.prototype.SetWorkItemLine = function (data, userId, imgName, elementName) {
        var content = "<em>No work item</em>";
        if(data && data.length > 0) {
            content = $.render.WorkItemTemplate(data);
        }
        $(imgName + userId).hide();
        $(elementName + userId).empty().append(content);
    };
    UsersList.prototype.dialogCheckUsers = function (urlCheck, urlSync) {
        $("<div></div>").dialog({
            title: "Check user",
            resizable: false,
            modal: true,
            width: 350,
            height: 250,
            buttons: {
                close: function () {
                    $(this).dialog("close");
                },
                "Apply": function () {
                    var dlg = $(this);
                    dlg.html('<center style="margin-top:70px"><span>Processing... </span><img  src="' + g_ImgDirectory + 'ajax-loader-l.gif" alt="Loading..."/></center>');
                    CallService("POST", urlSync, null, true, function () {
                        dlg.dialog("close");
                        window.location.reload(true);
                    });
                }
            },
            closeOnEscape: false,
            open: function () {
                var dlg = $(this);
                dlg.html('<center id="chkusr" style="margin-top:70px"><span>Checking users... </span><img  src="' + g_ImgDirectory + 'ajax-loader-l.gif" alt="Loading..."/></center>');
                CallService("GET", urlCheck, null, true, function (data) {
                    $("#chkusr").hide();
                    if(data > 0) {
                        dlg.html('<center style="margin-top:60px"> There is possibly <b>' + data + ' changes </b>between Scrumpilot users and TFS users. Click on Apply to synchronise them.</center>');
                    } else {
                        dlg.html('<center style="margin-top:70px">No change</center>');
                    }
                });
            }
        });
    };
    return UsersList;
})(Base.Page);
//@ sourceMappingURL=UsersList.js.map
